<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

<html>
<head>
  <meta charset="utf-8">
  <title>添加图书</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="${pageContext.request.contextPath}/lib/layui-v2.5.5/css/layui.css" media="all">
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/public.css" media="all">
  <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
  <style>
    body {
      background-color: #ffffff;
    }
  </style>
</head>
<body>
<div class="layui-container">
  <div class="col-md-4 column"  >
    <a class="btn btn-primary"  href="${pageContext.request.contextPath}/bookIndex">返回</a>
  </div>
  <div class="admin-login-background">
    <div class="layui-form login-form">
      <form class="layui-form" action="${pageContext.request.contextPath}/login/addBook" method="POST" enctype="multipart/form-data">
        <div class="layui-form-item">
          <label class="layui-icon layui-icon-username">书籍名称</label>
          <input type="text" name="bookName" placeholder="书籍名称" autocomplete="off"
                 class="layui-input" >
        </div>
        <div class="layui-form-item">
          <label class="layui-icon layui-icon-password">图书编号</label>
          <input type="text" name="bookID" placeholder="图书编号" autocomplete="off"
                 class="layui-input" >
        </div>
        <div class="layui-form-item">
          <label class="layui-icon layui-icon-username">图书类型</label>
          <select name="bookType">
            <option value="">请选择图书类型</option>
            <option value="文学类">文学类</option>
            <option value="历史类">历史类</option>
            <option value="工学类">工学类</option>
            <option value="法学类">法学类</option>
            <option value="经济学类">经济学类</option>
            <option value="统计学类">统计学类</option>
          </select>
        </div>
        <div class="layui-form-item">
          <label class="layui-icon layui-icon-password">图书作者</label>
          <input type="text" name="author" placeholder="图书作者" autocomplete="off"
                 class="layui-input" >
        </div>
        <div class="layui-form-item">
          <label class="layui-icon layui-icon-password">图书价格</label>
          <input type="text" name="price" placeholder="图书价格" autocomplete="off"
                 class="layui-input" >
        </div>
        <div class="layui-form-item">
          <label class="layui-icon layui-icon-password">图书</label>
          <input type="text" name="bookLanguage" placeholder="图书语言" autocomplete="off"
                 class="layui-input" >
        </div>
        <div class="layui-form-item">
          <button type="submit" class="layui-btn layui-btn layui-btn-normal layui-btn-fluid" lay-submit=" "
                  lay-filter="login">添加
          </button>
        </div>
      </form>
    </div>
  </div>
</div>
<script src="${pageContext.request.contextPath}/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script type="text/javascript">
  layui.use(['form', 'layer'], function () {
    var form = layui.form,
            layer = layui.layer;
    form.on('submit(login)', function (data) {
      console.log(data.field)
      var username = data.field.bookName;
      var passwords = data.field.bookID;
      var userType = data.field.bookType;
      console.log(username)
      if (username === '') {
        console.log(username);
        layer.msg('书籍名称不能为空');
        return false;
      }
      if (passwords === "") {
        layer.msg('图书编号不能为空');
        return false;
      }
      if (userType === "") {
        layer.msg('图书类型不能为空');
        return false;
      }
    });
  });
</script>
</body>
</html>